<template>
    <div class="login">
        <h1>登录</h1>
        <form @submit.prevent="dologin">
            <input type="text" v-model="user.userName" placeholder="账号">
            <input type="text" v-model="user.passWord" placeholder="密码">
            <button>登录</button>
        </form>
    </div>
</template>
<script>
import axios from "axios"
export default {
    data(){
        return{
            user:{
                userName:"",
                passWord:""
            }
        }
    },
    created(){},
    methods:{
        async dologin(){
            // this.$router.push("/")
            await axios.post("http://127.0.0.1:7001/dologin",{
                user:this.user
            }).then(res => {
                if(res.data.code !== 200){
                    return
                }
                localStorage.setItem("token",res.data.token)
                this.$router.push("/")
            })
        }
    }
}
</script>
<style scoped>

</style>